/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fonol.entidades;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Fredfred2
 */
@Entity
@Table(name = "CANDIDATOS")
@SequenceGenerator(name="seqCan",allocationSize=1,initialValue=1,sequenceName="CANDIDATOS_SEQ")
@NamedQueries({ @NamedQuery(name = "Candidatos.findByIdcandidato", query = "SELECT c FROM Candidatos c WHERE c.idcandidato = :idcandidato"), 
                @NamedQuery(name = "Candidatos.findByNombre", query = "SELECT c FROM Candidatos c WHERE c.nombre = :nombre"), 
                @NamedQuery(name = "Candidatos.findByRfc", query = "SELECT c FROM Candidatos c WHERE c.rfc = :rfc"), 
                @NamedQuery(name = "Candidatos.findByFechapeticion", query = "SELECT c FROM Candidatos c WHERE c.fechapeticion = :fechapeticion"), 
                @NamedQuery(name = "Candidatos.findByNombrerep", query = "SELECT c FROM Candidatos c WHERE c.nombrerep = :nombrerep"), 
                @NamedQuery(name = "Candidatos.findByAppatrep", query = "SELECT c FROM Candidatos c WHERE c.appatrep = :appatrep"), 
                @NamedQuery(name = "Candidatos.findByApmatrep", query = "SELECT c FROM Candidatos c WHERE c.apmatrep = :apmatrep"), 
                @NamedQuery(name = "Candidatos.findByEmail", query = "SELECT c FROM Candidatos c WHERE c.email = :email"), 
                @NamedQuery(name = "Candidatos.findByTelefono", query = "SELECT c FROM Candidatos c WHERE c.telefono = :telefono"), 
                @NamedQuery(name = "Candidatos.findByRazonsocial", query = "SELECT c FROM Candidatos c WHERE c.razonsocial = :razonsocial"),
                @NamedQuery(name = "Candidatos.findByDireccion", query = "SELECT c FROM Candidatos c WHERE c.direccion = :direccion"), 
                @NamedQuery(name = "Candidatos.findByDirrep", query = "SELECT c FROM Candidatos c WHERE c.dirrep = :dirrep"), 
                @NamedQuery(name = "Candidatos.findByRfcrep", query = "SELECT c FROM Candidatos c WHERE c.rfcrep = :rfcrep"),
                @NamedQuery(name = "Candidatos.findByEstado", query = "SELECT c FROM Candidatos c WHERE c.estado = :estado"),
                @NamedQuery(name = "Candidatos.findByEstadoNoBeneficiarios", query = "SELECT c FROM Candidatos c WHERE c.estado = :estado and c.beneficiariosCollection is empty")})
public class Candidatos implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(generator="seqCan",strategy=GenerationType.SEQUENCE)
    @Column(name = "IDCANDIDATO", nullable = false)
    private Integer idcandidato;
    @Column(name = "NOMBRE")
    private String nombre;
    @Column(name = "RFC")
    private String rfc;
    @Column(name = "FECHAPETICION")
    @Temporal(TemporalType.DATE)
    private Date fechapeticion;
    @Column(name = "NOMBREREP")
    private String nombrerep;
    @Column(name = "APPATREP")
    private String appatrep;
    @Column(name = "APMATREP")
    private String apmatrep;
    @Column(name = "EMAIL")
    private String email;
    @Column(name = "TELEFONO")
    private String telefono;
    @Column(name = "RAZONSOCIAL")
    private String razonsocial;
    @Column(name = "DIRECCION")
    private String direccion;
    @Column(name = "DIRREP")
    private String dirrep;
    @Column(name = "RFCREP")
    private String rfcrep;
    
    @Enumerated
    @Column(name = "ESTATUS")
    private EstatusCandidato estatus=EstatusCandidato.ESPERA;
    
    @JoinColumn(name = "IDESTADO", referencedColumnName = "IDESTADO")
    @ManyToOne
    private Estados estado;
                @OneToMany(mappedBy = "candidatos")
    private Collection<Beneficiarios> beneficiariosCollection;

    public Candidatos() {
    }

    public Candidatos(Integer idcandidato) {
        this.idcandidato = idcandidato;
    }

    public Integer getIdcandidato() {
        return idcandidato;
    }

    public void setIdcandidato(Integer idcandidato) {
        this.idcandidato = idcandidato;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getRfc() {
        return rfc;
    }

    public void setRfc(String rfc) {
        this.rfc = rfc;
    }

    public Date getFechapeticion() {
        return fechapeticion;
    }

    public void setFechapeticion(Date fechapeticion) {
        this.fechapeticion = fechapeticion;
    }

    public String getNombrerep() {
        return nombrerep;
    }

    public void setNombrerep(String nombrerep) {
        this.nombrerep = nombrerep;
    }

    public String getAppatrep() {
        return appatrep;
    }

    public void setAppatrep(String appatrep) {
        this.appatrep = appatrep;
    }

    public String getApmatrep() {
        return apmatrep;
    }

    public void setApmatrep(String apmatrep) {
        this.apmatrep = apmatrep;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getTelefono() {
        return telefono;
    }

    public void setTelefono(String telefono) {
        this.telefono = telefono;
    }

    public String getRazonsocial() {
        return razonsocial;
    }

    public void setRazonsocial(String razonsocial) {
        this.razonsocial = razonsocial;
    }

    public String getDireccion() {
        return direccion;
    }

    public void setDireccion(String direccion) {
        this.direccion = direccion;
    }

    public String getDirrep() {
        return dirrep;
    }

    public void setDirrep(String dirrep) {
        this.dirrep = dirrep;
    }

    public String getRfcrep() {
        return rfcrep;
    }

    public void setRfcrep(String rfcrep) {
        this.rfcrep = rfcrep;
    }

    public Estados getEstado() {
        return estado;
    }

    public void setEstado(Estados estado) {
        this.estado = estado;
    }

    public Collection<Beneficiarios> getBeneficiariosCollection() {
        return beneficiariosCollection;
    }

    public void setBeneficiariosCollection(Collection<Beneficiarios> beneficiariosCollection) {
        this.beneficiariosCollection = beneficiariosCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idcandidato != null ? idcandidato.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Candidatos)) {
            return false;
        }
        Candidatos other = (Candidatos) object;
        if ((this.idcandidato == null && other.idcandidato != null) || (this.idcandidato != null && !this.idcandidato.equals(other.idcandidato))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fonol.entidades.Candidatos[idcandidato=" + idcandidato + "]";
    }

    public EstatusCandidato getEstatus() {
        return estatus;
    }

    public void setEstatus(EstatusCandidato estatus) {
        this.estatus = estatus;
    }

}
